pub struct CsvReader<'a> {
    view: &'a str,
}

impl<'a> CsvReader<'a> {
    pub fn new(src_slice: &'a str) -> Self {
        Self {
            view: src_slice,
        }
    }

    pub fn read_item(&mut self) -> Option<String> {
        if self.view.is_empty() {
            return None;
        }

        let sp = self.view.find(|c| c == ',' || c == '\n');
        if let Some(idx) = sp {
            let item = Some(String::from(&self.view[..idx]));
            if !self.view.is_empty() {
                self.view = &self.view[idx+1..];
            }

            item
        } else {
            let item = Some(String::from(&self.view[..]));
            self.view = "";

            item
        }
    }
}
